$(function(){

    initPage();
})
var pageNum = 0;
function initPage(){
    $("#more").remove();
    $.ajax({
        url:server_url + '/rest/supply/product/trend.do?pageNum='+pageNum+"&userId="+userid,
        data:{ran:Math.random()},
        success:function(data){
            console.log(data)
            if (data.data != null && data.data.length > 0){
                var orders = data.data;
                var html = '';
                for (var i=0; i<orders.length;i++){
                    var order = orders[i];
                    html += '<div class="det_box">\
                    <img src="'+order.picturePath1+'" alt="" class=""/>\
                    <div class="">\
                    <div class="con_tit">\
                    <p>'+order.productName+'</p>\
                    <span>¥'+order.price+'/头</span>\
                    </div>\
                    <p class="con_normal">类别：'+order.specName+'</p>\
                    <p class="con_normal">货源地：'+order.areaName+'</p>\
                    <p class="con_normal">成交量：'+order.overPlusNum+'头</p>\
                    <p class="con_normal">成交时间：'+order.addTime.substring(0,10)+'</p>\
                    </div>\
                    </div>';
                }
                if (userid == null || userid == ''){
                    $("#prodList").append(html);
                    $("#login").show();
                    $("#login").click(function(){
                        window.location.href = '/LianniuWeb/login.do?supply=1';
                    });
                }else{
                    html +="<div id='more' onclick='initPage();' style=\"text-align: center\">加载更多</div>";
                    $("#prodList").append(html);
                    pageNum++;
                }
            }
        }
    })
}